;;; org-settings.el --- 

;; Copyright 2011 zhjw
;;
;; Author: zheng.jinwei2944@gmail.com
;; Version: $Id: org-settings.el,v 0.0 2011/04/07 09:02:20 user1 Exp $
;; Keywords: 
;; X-URL: not distributed yet

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;; 

;; Put this file into your load-path and the following into your ~/.emacs:
;;   (require 'org-settings)

;;; Code:

(provide 'org-settings)
(eval-when-compile
  (require 'cl))



;;;;##########################################################################
;;;;  User Options, Variables
;;;;##########################################################################


;; (add-to-list 'load-path "~/emacs/site-lisp/org")
(add-to-list 'load-path (concat cpz-emacs-lisp-path "org"))
(require 'org-install)

(defun org-settings()
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)

;; 在ORG－MODE中自动换行
(add-hook 'org-mode-hook
    (lambda () (setq truncate-lines nil)))


;; Capture setup
;; (setq org-default-notes-file (cons org-directory "/notes.org"))
(setq org-default-notes-file "d:/home/orgnote/notes.org")
(define-key global-map "\C-cc" 'org-capture)


 (custom-set-variables
   ;; custom-set-variables was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
  '(org-agenda-files (quote ("d:/home/orgnote/life.org" "d:/home/orgnote/work.org"))))
 (custom-set-faces
   ;; custom-set-faces was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
  )

;; My custom LaTeX class for Org-mode export. require is needed for it to work.
;; You can use this as a template to create your own preamble for Org-mode by putting whatever you like your preamble to contain between '("myarticle" " and and [NO-DEFAULT-PACKAGES].
; (require 'org-latex)

; (add-to-list 'org-export-latex-classes
;              '("myarticle"
; 			   "\\documentclass[a4paper,12pt]{article}

; \\usepackage[utf8]{inputenc}
; \\usepackage{lmodern}
; \\usepackage[T1]{fontenc}

; \\usepackage{fixltx2e}

; \\newcommand\\foo{bar}
;                [NO-DEFAULT-PACKAGES]
;                [NO-PACKAGES]
;                [EXTRA]"
;                ("\\section{%s}" . "\\section*{%s}")
; 			   ("\\subsection{%s}" . "\\subsection*{%s}")
; 			   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
; 			   ("\\paragraph{%s}" . "\\paragraph*{%s}")
; 			   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

(require 'org-latex)
(unless (boundp 'org-export-latex-classes) 
  (setq org-export-latex-classes nil))

;; 输出latex模板
;; export to Tex or PDF
(setq org-export-latex-coding-system 'utf-8)
(setq org-export-latex-date-format "%Y/%m/%d")
(setq org-export-latex-default-class "article")
(add-to-list 'org-export-latex-classes
			 '("myarticle"
			   "\\documentclass[a4paper,12pt]{article}

\\usepackage{xeCJK}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{hyperref}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\usepackage{xcolor}

\\newcommand{\\makeheadrule}{%  
  \\makebox[0pt][l]{\\rule[.7\\baselineskip]{\\headwidth}{0.8pt}}%  
  \\rule[0.85\\baselineskip]{\\headwidth}{1.5pt}\\vskip-.8\\baselineskip}  

\\makeatletter  
\\renewcommand{\\headrule}{%  
  {\\if@fancyplain\\let\\headrulewidth\\plainheadrulewidth\\fi  
    \\makeheadrule}}  
\\makeatother  

\\setCJKfamilyfont{YaHei}{Microsoft YaHei}
\\setCJKfamilyfont{kt}{KaiTi}
\\setCJKfamilyfont{dfkt}{DFKai-SB}
\\setCJKfamilyfont{stxw}{STXinwei}
\\setCJKfamilyfont{fzxy}{FZXiYuan-M01}
\\setCJKfamilyfont{ht}{SimHei}
\\setCJKfamilyfont{stzs}{STZhongsong}
\\setCJKfamilyfont{fzst}{FZShuTi}
\\setCJKfamilyfont{ls}{LiSu}
\\setCJKfamilyfont{jhh}{Microsoft JhengHei}
\\setCJKfamilyfont{stcy}{STCaiyun}
\\setCJKfamilyfont{stxh}{STXihei}
\\setCJKfamilyfont{stfs}{STFangsong}
\\setCJKfamilyfont{stkt}{STKaiti}
\\setCJKfamilyfont{stst}{STSong}
\\setCJKfamilyfont{stlt}{STLiti}
\\setCJKfamilyfont{fzyt}{FZYaoTi}
\\setCJKfamilyfont{sthp}{STHupo}
\\setCJKfamilyfont{ml}{MingLiU}
\\setCJKfamilyfont{pml}{PMingLiU}
\\setCJKfamilyfont{fs}{FangSong}
\\setCJKfamilyfont{xst}{NSimSun}
\\setCJKfamilyfont{stxk}{STXingkai}
\\setCJKfamilyfont{yy}{YouYuan}

\\setmainfont{Times New Roman}
\\setCJKmainfont{SimSun}

\\parindent 2em
\\setlength{\\parskip}{1ex plus 0.5ex minus 0.2ex}
                 [NO-DEFAULT-PACKAGES]
                 [NO-PACKAGES]
                 [EXTRA]"
			   ("\\section{%s}" . "\\section*{%s}")
			   ("\\subsection{%s}" . "\\subsection{%s}")
			   ("\\subsubsection{%s}" . "\\subsubsection{%s}")
			   ;; ("\\paragraph{%s}" . "\\paragraph{%s}")
			   ;; ("\\subparagraph{%s}" . "\\subparagraph{%s}")
			   ))

;; My custom  class for Org-mode export. require is needed for it to work.
;; For exporting to beamer you can instead use #+LaTeX_CLASS: beamer. This exports to beamer with a given preamble. If you want to define the beamer preamble yourself you can do as follows. Put the following in your .emacs:
;; This also requires (require 'org-latex) in your preamble. You can include whatever you like your preamble to include between '("mybeamer" and [NO-DEFAULT-PACKAGES]. To export an Org buffer to this class it has to include #+LaTeX_CLASS: mybeamer.
(add-to-list 'org-export-latex-classes
			 '("mybeamer"
			   "\\documentclass[presentation]{beamer}

                 [NO-DEFAULT-PACKAGES]
                 [NO-PACKAGES]
                 [EXTRA]
                 [BEAMER-HEADER-EXTRA]"
			   org-beamer-sectioning))


(setq org-latex-to-pdf-process
	  '("xelatex -interaction nonstopmode %f"
		"xelatex -interaction nonstopmode %f"))

)

(eval-after-load "org" `(org-settings))

;;; org-settings.el ends here
